<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="com.yaodian100.core.common.utils.ServerValue" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ include file="/taglibs.jsp" %>

<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>' />

<script language="javascript">
	$().ready(function(){
		$("#disapproveBtn").click(function(){
			if($("#receiveDisapproveReason").val()==""){
				alert("请输入不核可原因");
				return false;
			}
			
			if(confirm("是否确定不核可?")){
				$("#isApprove").attr("value","false");
				$("#approveForm").submit();
			}
		});
		
		$("#approveBtn").click(function(){
			if(confirm("是否确定核可?")){
				$("#isApprove").attr("value","true");
				$("#approveForm").submit();
			}
		});
	});
</script>

<h1>礼品卡管理 - 领用检示</h1>

<s:if test="hasActionErrors()">
	<s:actionerror cssClass="msg rn"/><p />
</s:if>
<s:if test="hasActionMessages()">
	<s:actionmessage cssClass="msg rn"/><p />
</s:if>
<s:if test="hasFieldErrors()">
	<s:fielderror cssClass="msg rn"/><p />
</s:if>

<div class="f-link">
	<a href="${midContextPath}/giftcard/receiveList.do">返回礼品卡领用管理查询</a>
</div>
<br />
<br />
&nbsp;
<table class="tb-data" width="100%">
	<tr>
		<th width="25%">申请人</th>
		<td>
			${giftcardReceiveMain.applyUser}
		</td>
	</tr>
	<tr>
		<th>领用人</th>
		<td>
			${giftcardReceiveMain.receiveUser}
		</td>
	</tr>
	<tr>
		<th>状态</th>
		<td>
			${giftcardReceiveQueryStatusMenu.options[giftcardReceiveMain.status].name}
		</td>
	</tr>
	<tr>
		<th>核可处理人员</th>
		<td>
			${giftcardReceiveMain.approveUser}
		</td>
	</tr>
	<tr>
		<th>核可日期</th>
		<td>
			<fmt:formatDate value="${giftcardReceiveMain.approveDate}" pattern="yyyy-MM-dd HH:mm:ss" />
		</td>
	</tr>
	<tr>
		<th>申请/领用日期</th>
		<td>
			<fmt:formatDate value="${giftcardReceiveMain.receiveDate}" pattern="yyyy-MM-dd HH:mm:ss" />
		</td>
	</tr>
	<tr>
		<th>建立人</th>
		<td>
			${giftcardReceiveMain.createUser}
		</td>
	</tr>
	<tr>
		<th>建立时间</th>
		<td>
			<fmt:formatDate value="${giftcardReceiveMain.createDate}" pattern="yyyy-MM-dd HH:mm:ss" />
		</td>
	</tr>
	<tr>
		<th>修改人</th>
		<td>
			${giftcardReceiveMain.modifyUser}
		</td>
	</tr>
	<tr>
		<th>修改时间</th>
		<td>
			<fmt:formatDate value="${giftcardReceiveMain.modifyDate}" pattern="yyyy-MM-dd HH:mm:ss" />
		</td>
	</tr>
</table>
<br />
<c-rt:set var="receiveTotalCount" value='0' />
<c-rt:set var="receiveTotalAmount" value='0' />
<table width="100%">
	<thead class="tb-1">
		<tr>
			<th>面额</th>
			<th>张数</th>
			<th>小计</th>
		</tr>
	</thead>
	<tbody class="tb-1">
		<c:forEach items="${giftcardReceiveItems}" var="giftcardReceiveItem" varStatus="rows_index">
			<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
				<td>${giftcardReceiveItem.amount}</td>
				<td>${giftcardReceiveItem.count}</td>
				<c-rt:set var="receiveTotalCount" value='${receiveTotalCount+giftcardReceiveItem.count}' />
				<td>${giftcardReceiveItem.amount*giftcardReceiveItem.count}</td>
				<c-rt:set var="receiveTotalAmount" value='${receiveTotalAmount+(giftcardReceiveItem.amount*giftcardReceiveItem.count)}' />
			</tr>
		</c:forEach>
	</tbody>
	<tr>
		<td>
			总计张数：${receiveTotalCount}
		</td>
		<td colspan="2">
			总计金额：${receiveTotalAmount}
		</td>
	</tr>
	<tr>
		<td colspan="3">
		<s:form action="approve.do" method="post" id="approveForm">
			不核可原因：
			<input type="text" name="receiveDisapproveReason" id="receiveDisapproveReason" maxlength="255" size="100" />
		<yaodian100:checkPermission permissions="ROLE_GIFTCARDMANAGER">
			<input type="button" name="disapproveBtn" id="disapproveBtn" value="不核可" />
			<input type="button" name="approveBtn" id="approveBtn" value="核可" />
		</yaodian100:checkPermission>
			<input type="hidden" name="receiveId" value="${receiveId}" />
			<input type="hidden" name="isApprove" id="isApprove" />
		</s:form>
		</td>
	</tr>
</table>